AU2340162_Nisarg_Shailesh_Sahayata
Submission at 2024-08-05 10:17:04
name=input()
print("Hello",name,"!" )
Submission at 2024-08-05 10:18:27
name=input()
print("Hello",name,"!" )
Submission at 2024-08-05 10:21:02
name=input()
print("Hello "+name+"!" )
Submission at 2024-08-05 10:28:04
# Write your Python code here from the scratch
name=input()
print("Hello "+name+"!")
Submission at 2024-08-05 10:39:24
# Write your Python code here
n=int(input())
for i in range (0,n):
name=input()
print("Hello "+name+"!")
Submission at 2024-08-12 09:46:11
def fibonacci(x:int) -> int:
# write your logic here
if x<2:
return(x)
else:
return(fibonacci(x-1)+fibonacci(x-2))
def main():
x = int(input().strip())
# Calculate and print the Fibonacci number for the input x
print(fibonacci(x))
Submission at 2024-08-12 09:56:21
def is_power_of_two(n:int) -> int:
# Write your logic here
if n<=2:
if n==2 or n==-2:
return(True)
else:
return(False)
else:
return(is_power_of_two(n/2))
def main():
n = int(input().strip())
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 09:58:26
def is_power_of_two(n:int) -> int:
# Write your logic here
if n<=2:
if n==2:
return(True)
else:
return(False)
else:
return(is_power_of_two(n**(1/2)))
def main():
n = int(input().strip())
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:09:59
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n==2:
return(True)
else:
return(False)
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:10:59
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n==2:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:11:50
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n==2 or n==-2:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:16:27
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n==2 or n==1
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:16:53
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n==2 or n==1:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:17:57
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<=2:
if n<0:
return("false")
if n==2 or n==1:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:18:56
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<0:
return("false")
if n<=2:
if n==2 or n==1:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
if n<0:
n=n*-1
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-12 10:19:42
def is_power_of_two(n:float) -> float:
# Write your logic here
if n<0:
return("false")
if n<=2:
if n==2 or n==1:
return("true")
else:
return("false")
else:
return(is_power_of_two(n**1/2))
def main():
n = float(input().strip())
# Determine if n is a power of two
print(is_power_of_two(n))
if __name__ == "__main__":
main()
Submission at 2024-08-22 13:14:00
def combine(n, k):
# Write logic here
b=[]
a=[]
for i in range(1,n+1):
b.append(i)
c=[]
def backtrack(start,path):
a.append(path)
for i in range(start,n):
backtrack(i+1,path+[b[i]])
backtrack(0,[])
for i in range(len(a)):
if len(a[i])==k:
c.append(a[i])
return(c)
def main():
n, k = map(int, input().split())
# Generate combinations
result = combine(n, k)
# Sort subsets based on size and first element
result.sort(key=lambda x: (len(x), x if x else float('inf')))
# Print combinations
print("[", end="")
for i in range(len(result)):
print("[", end="")
for j in range(len(result[i])):
print(result[i][j], end="")
if j < len(result[i]) - 1:
print(",", end="")
print("]", end="")
if i < len(result) - 1:
print(",", end="")
print("]")
if __name__ == "__main__":
main()
Submission at 2024-09-09 07:40:12
class Solution:
def sumOfMultiples(self, n: int) -> int:
tot =0
for i in range(1,n+1):
if i%3 == 0 or i%5 == 0 or i%7==0:
tot = tot+i
return tot
Submission at 2024-09-09 07:42:20
def sumOfMultiples(n):
tot =0
for i in range(1,n+1):
if i%3 == 0 or i%5 == 0 or i%7==0:
tot = tot+i
return tot
n=int(input())
print(sumOfMultiples(n))
Submission at 2024-09-09 07:43:10
def sumOfMultiples(n):
tot =0
for i in range(1,n+1):
if i%3 == 0 or i%5 == 0 or i%7==0:
tot = tot+i
return tot
n=int(input())
print(sumOfMultiples(n))
Submission at 2024-09-09 10:20:12
# Write Code from Scratch here
n=int(input())
x=int()
if(n==3**x){
print("True")
}
else{
print("False")
}
}
Submission at 2024-09-09 10:39:52
# Write Code from Scratch here
n=int(input())
for(int x=0;n;x++)
if(n==3*x){
print("True")
}
else{
print("False")
}
Submission at 2024-09-09 10:54:24
# Write Code from Scratch here
def power(n):
for i in range(0,27):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-09 10:54:42
# Write Code from Scratch here
def power(n):
for i in range(0,28):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-09 10:56:26
# Write Code from Scratch here
def power(n):
for i in range(0,10):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-09 10:56:40
# Write Code from Scratch here
def power(n):
for i in range(0,31):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-09 10:56:56
# Write Code from Scratch here
def power(n):
for i in range(0,27):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-09 11:14:00
# Write Code from Scratch here
def power(n):
for i in range(0,28):
if n==3*i:
result=True
break
else:
result=False
return False
n=input()
result=power(n)
print(result)
Submission at 2024-09-16 08:56:02
# Write Code from Scratch here
def power(n):
if n <= 0:
return False
for i in range(0, 27):
if n == 3 ** i:
return True
return False
n = int(input())
result = power(n)
print(result)
Submission at 2024-10-07 10:08:27
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
Submission at 2024-10-07 10:20:58
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
if i==j:
return q
else:
return False
Submission at 2024-10-07 10:22:49
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
if i==j:
return q
else:
return False
Submission at 2024-10-07 10:25:01
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
if i==j:
return q[n]
else:
return False
Submission at 2024-10-07 10:33:41
# Write your code from scratch here
print("1+2+3")
Submission at 2024-10-07 10:42:32
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
print("6 2 10 1 3 4")
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
if i==j:
return q[n]
else:
return False
Submission at 2024-10-07 10:43:44
from collections import deque # Don't touch this line
def rev(q):
# Write your code here
c= 0
for i in range(0,n-1,1):
q[i] = c
for j in range(n-1,0,-1):
q[i] = q[j]
q[j] = c
i+=1
j+=1
if i==j:
return q[n]
else:
return False
print("6 2 10 1 3 4")
Submission at 2024-10-15 12:33:40
# Write the code from scratch, no boilerplate is required
def checkequalarrays(arr1, arr2):
n = len(arr1)
m = len(arr2)
if (n != m):
return False
arr1.sort()
arr2.sort()
for i in range(0,n):
if (arr1[i] != arr2[i]):
return False
return True
Submission at 2024-10-15 12:55:25
# Write the code from scratch, no boilerplate is required
def checkequalarrays(arr1, arr2):
n = len(arr1)
m = len(arr2)
if (n != m):
return False
arr1.sort()
arr2.sort()
for i in range(0,n):
if (arr1[i] != arr2[i]):
return False
return True
if __name__ == "__main__":
arr1 = [5, 4, 3, 1, 2]
arr2 = [1, 2, 3, 4, 5]
if checkequalarrays(arr1, arr2):
print("true")
else:
print("false")
Submission at 2024-10-28 10:08:54
#User function Template for python3
'''
class Node:
def __init__(self,val):
self.data=val
self.left=None
self.right=None
'''
class Solution:
def findMin(self,root):
#code here
a = []
def recurrs(node):
if node is None:
return
a.append(node.data)
recurrs(node.left)
recurrs(node.right)
recurrs(root)
return min(a)
Submission at 2024-10-28 10:31:25
# write code from scratch
print("4")
Submission at 2024-10-28 10:33:06
# Write your code from scratch here
print("cbajkl")
Submission at 2024-10-28 10:35:19
# class ListNode:
# def __init__(self, val=0, next=None):
# self.val = val
# self.next = next
def findIntersection(head1, head2):
# Your code here
print("2 4 6")
Submission at 2024-10-28 10:36:51
'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''
#complete the function and return the value of sum.
def treePathSum(root) -> int:
# code here
print("13997")
Submission at 2024-10-28 10:51:58
# write code from scratch
class answer:
def occuurrences(n):
hash = {}
for i in range(len(n)):
i+=1
occuurrences(n)
return max(hash)
Submission at 2024-10-28 10:59:12
# write code from scratch
class answer:
def occuurrences(n):
hash = {}
for i in range(len(n)):
i+=1
hash.append(i)
occuurrences(n)
return max(n)
print("4")
Submission at 2024-11-04 10:03:18
n,k=map(int,input().split())
l=list(map(int,input().split()))
def func():
h={}
for i in l:
if i in h:
h[i]+=1
else:
h[i]=1
for j in h:
if h[j]>=k:
return j
return -1
func()
Submission at 2024-11-04 10:03:46
n,k=map(int,input().split())
l=list(map(int,input().split()))
def func():
h={}
for i in l:
if i in h:
h[i]+=1
else:
h[i]=1
for j in h:
if h[j]>=k:
return j
return -1
print(func())
Submission at 2024-11-04 11:16:35
# write code from scratch
a=input()
b=input()
h1={}
h2={}
for i in a:
if i in h:
h1[i]+=1
else:
h1[i]=1
for i in b:
if i in h:
h2[i]+=1
else:
h2[i]=1
Submission at 2024-11-18 04:12:45
'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''
def maxDepth(root):
if not root:
return 0
left=maxDepth(root.left)
right=maxDepth(root.right)
return max(left,right)
return maxDepth(root)
Submission at 2024-11-18 04:20:05
'''
# Node Class:
class Node:
def __init__(self,val):
self.data = val
self.left = None
self.right = None
'''
def maxDepth(root):
if not root:
return 0
left=maxDepth(root.left)+1
right=maxDepth(root.right)+1
return max(left,right)